home *** CD-ROM | disk | FTP | other *** search
- (c) Copyright 1990 Commodore-Amiga, Inc. All rights reserved.
- The information contained herein is subject to change without notice,
- and is provided "as is" without warranty of any kind, either express
- or implied. The entire risk as to the use of this information is
- assumed by the user.
-
-
- Reading Mac Sound Files
-
- by John Orr
-
- There is little difference between the raw data of Amiga and
- Apple Macintosh (and Apple IIgs) sound samples. Both machines
- record and play digitized sound in 8-bit samples. The only
- difference between their raw data formats lies in how the sound
- wave is plotted.
-
- Sound samples on an Amiga are represented as a positive or
- negative offset from zero, ranging from -128 to 127. A value of
- zero represents no sound (see fig. 1). Mac samples on the other
- hand, are represented as a positive offset from zero, but here
- zero represents the part of a sound wave that is of the greatest
- possible negative amplitude. Macintosh sample data ranges from 0
- to 255 with silence represented by a value of 128 (see fig. 2).
-
- Naturally, the sound data must be converted to cross from one
- platform to the other. Without any conversion, a sine wave
- sampled on one platform would look like figure 3 on the other
- platform.
-
- One simple way to convert a sample from Amiga to Apple format
- would be to add 128 to each byte in the sample. Conversely, to
- convert from Apple to Amiga, you could subtract 128 from each
- byte. But both cases can be handled more simply by reversing the
- high bit of each byte in the sample. This one process will
- convert a sample of one type to the other. Hence, performing an
- exclusive OR with 0x80 on each byte in the sample will generate
- the desired result.
-
- Transferring the Data
-
- Before converting a Mac audio sample to Amiga format, another
- problem has to be considered: obtaining Mac sound data. There
- are several straight-forward methods of transferring data from
- one platform to the other. A direct serial line transfer can be
- performed between the Amiga's RS-232 serial port and the Mac's
- RS-422 serial port. Another way the two machines can share data
- is through the use of a product such as Central Coast Software's
- Mac-2-DOS which comes with a disk drive that can read and write
- both Mac and Amiga formats. The A-Max Macintosh emulator from
- ReadySoft offers yet another convenient way of moving data
- across from one platform to the other.
-
- Macintosh File Conventions
-
- The Mac filing system has an unusual method of storing files.
- Files are broken up into two parts, a data fork and a resource
- fork. In the case of audio samples, the data fork typically
- contains the actual sound sample, while the the resource fork
- contains various parameters of the sound such as recording and
- playback rate. In general, when transferring Mac files to the
- Amiga, only the data fork is needed by the Amiga. Mac-2-DOS and
- most Mac terminal packages are capable of transferring just the
- data fork part of the file by itself.
-
- Another thing to note about Mac files is that they have a file
- type and creator associated with them. In the case of sampled
- sound files, the file type is FSSD. When transferring Amiga
- files over to the Mac, the file must be given the FSSD file type,
- otherwise Mac sound applications generally will not read the
- file. Mac-2-DOS is capable of specifying the file type field as
- it copies Amiga files to a Mac floppy. If you are using some
- other transfer method, then the file type can be changed to FSSD
- on the Mac end by using a utility such as ResEdit.
-
- The creator field depends on what application created the file.
- A popular sound sampler/editor for the Mac is SoundEdit, which is
- akin to the Amiga's AudioMaster II. SoundEdit's creator field is
- SFX!.
-
- It should be mentioned that in certain cases, sound data on a Mac
- is stored in the resource fork in an entity known as a sound
- resource. The Mac sys-beep is an example of this. It is
- possible to convert a Mac sound resource to the FSSD file type --
- this is left as an exercise for the reader.
-
-
- Audio Sample File Formats: Raw vs. IFF
-
- When transferring Amiga sounds to the Mac, it's important to
- remember that Mac sound samples are usually saved as raw data.
- On the Amiga however, sampled sounds are usually stored in the
- IFF 8SVX format. The 8SVX format contains a header chunk called
- the VHDR which has global information about the sample such as
- the sampling rate and compression used. This is followed by a
- BODY chunk which contains the raw sound data. For the Mac to
- interpret an Amiga sample correctly, only the raw data should be
- present. Likewise, a Mac sample should be converted to 8SVX for
- use on the Amiga.
-
- SunRize Industries' Perfect Sound is capable of reading and
- writing both raw sound data and IFF 8SVX data which makes it a
- handy conversion tool. Another option is Aegis' AudioMaster II
- software which includes a utility that can strip an 8SVX file
- down to a raw data file. Note that for stereo samples, both
- platforms store the raw data in the same order -- the left
- channel first followed by the right channel. So, stereo and mono
- samples are converted using the same methods.
-
- Recently, Apple adopted another standard for storing sound
- samples. It is based on the IFF model of data storage and is
- called the Audio Interchange File Format (AIFF). It is similar
- in many ways to 8SVX, but is intended to be more versatile. The
- AIFF standard has not yet been widely accepted, and consequently,
- commonly found samples are not stored in this format. More
- information on this format can be found in Apple documentation.
-
- Sampling Speeds
-
- After a sound sample has been copied from one medium to the
- other, a playback rate has to be determined since this
- information is not preserved in transferring raw data. Mac
- sounds digitized with SoundEdit and MacRecorder -- a popular Mac
- sound digitizer -- are sampled at four different speeds: 22kHz,
- 11kHz, 7kHz, and 5kHz. Amiga audio samples normally vary in
- recording speed and can be as fast as 28,867 bytes/second. The
- table below shows the four MacRecorder sampling rates and their
- Amiga equivalents.
-
-
- The example code below will convert raw sound samples to and from
- the Amiga and Mac formats. It is important to remember that this
- program works only with raw data. 8SVX samples must be stripped
- of the added IFF information, before they can be converted.
-
-
-
- /*
- * convertsound.c - Converts raw sound data back and
- * forth from a Macintosh/Apple IIgs format to the Amiga
- * format.
- */
-
- #include <exec/types.h>
- #include <libraries/dosextens.h>
-
- #define BUFSIZE 32767
-
- struct FileHandle *Open(char *, LONG);
-
- UBYTE buffer[BUFSIZE];
-
- void main(int argc, char **argv)
- {
- struct FileHandle *fh_in, *fh_out;
- WORD count_in, count_out, x = 0;
-
- if (argc != 3)
- {
- printf("usage:\n\t%s <infile> <outfile>",argv[0]);
- exit(30);
- }
- if (fh_in = Open(argv[1], MODE_OLDFILE))
- {
- if (fh_out = Open(argv[2], MODE_NEWFILE))
- {
- do
- {
- count_in = Read(fh_in, buffer, BUFSIZE);
- for (x=0; x < count_in; x++)
- buffer[x] ^= 0x80;
- count_out = Write(fh_out, buffer, count_in);
- } while (count_in > 0);
-
- Close(fh_out);
- }
- Close(fh_in);
- }
- }
-